<template>
	<view class="container">
		<!-- <u-navbar bgColor="#0065FF" titleStyle="color:#fff;" leftIconColor="#fff" title="我的" autoBack placeholder> -->
		<view slot="left"></view>
		</u-navbar>
		<view class="content">
			<view class="user_info">
				<u-avatar size="120rpx" :src="$tool.oss(userInfo.avatar)"></u-avatar>
				<view class="right">
					<text>{{ userInfo.nickName }}</text>
					<text>{{ userInfo.userName | userInfo.phonenumber }}</text>
				</view>
			</view>
			<view class="menu">
				<view class="item" @click="onPage('/pagesB/company/info')">
					<view class="left">
						<i class="iconfont icon-gongsi1"></i>
						<text>公司管理</text>
					</view>
					<u-icon color="#0065FF" name="arrow-right"></u-icon>
				</view>
				<view class="item" @click="onPage('/pagesB/project/log')">
					<view class="left">
						<i class="iconfont icon-toubiao1"></i>
						<text>投标记录</text>
					</view>
					<u-icon color="#0065FF" name="arrow-right"></u-icon>
				</view>
				<view class="item" @click="onPage('/pagesB/editPwd')">
					<view class="left">
						<i class="iconfont icon-xiugaimima"></i>
						<text>修改密码</text>
					</view>
					<u-icon color="#0065FF" name="arrow-right"></u-icon>
				</view>
			</view>
			<view class="btn">
				<u-button @click="logout" color="#0065FF" text="退出登录"></u-button>
			</view>
		</view>
	</view>
</template>

<script>
	// import config from '@/http/config.js';
	export default {
		data() {
			return {
				userInfo: {},
				baseUrl: ''
			};
		},
		onLoad() {
			this.userInfo = this.$store.state.user
			console.log(this.userInfo)
			// this.getUserInfo();
		},
		filters: {
			phoneFilter(e) {
				return e?.replace(/(\d{3})\d*(\d{2})/, '$1******$2');
			}
		},
		methods: {
			// async getUserInfo() {
			// 	const { data } = await this.$api.userInfo();
			// 	this.userInfo = data.user;
			// 	uni.setStorageSync('companyId', data.user.company_id);

			// },
			onPage(path) {
				uni.navigateTo({
					url: path
				});
			},
			async logout() {
				// const { data } = await this.$api.userLogout();
				// uni.clearStorageSync()
				// uni.removeStorageSync('token');
				this.$store.commit('user/setUserInfo', {
					id: null,
					isLogin: false,
					access_token: null,
					avatar: null,
					phonenumber: null,
					nickName: null,
					userName: null,
					people: {},
					dept: {},
				})
				uni.reLaunch({
					url: '/pages/login'
				});
			}
		}
	};
</script>

<style lang="scss" scoped>
	.user_info {
		padding: 40rpx 20rpx;
		background-color: #fff;
		display: flex;
		background-color: #0065ff;

		.right {
			padding: 0 20rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-around;
			font-size: 24rpx;
			color: #fff;

			>text:first-of-type {
				font-size: 34rpx;
				font-weight: bold;
				margin-bottom: 6rpx;
			}
		}
	}

	.menu {
		padding: 20rpx;
		margin-bottom: 60rpx;

		.item {
			background-color: #fff;
			margin-bottom: 20rpx;
			padding: 20rpx;
			font-size: 28rpx;
			border-radius: 10rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.left {
				display: flex;
				align-items: center;

				>i {
					margin-right: 10rpx;
					color: #0065ff;
				}
			}
		}
	}

	.btn {
		padding: 20rpx;

		/deep/ .u-button {
			border-radius: 20rpx;
		}
	}
</style>